# Contributor: techknowlogick <techknowlogick@gitea.io>
# Maintainer: techknowlogick <techknowlogick@gitea.io>
pkgname=helm
pkgver=3.16.2
pkgrel=0
pkgdesc="The Kubernetes Package Manager"
url="https://helm.sh/"
arch="all"
license="Apache-2.0"
makedepends="bash go"
options="net"
subpackages="$pkgname-bash-completion $pkgname-fish-completion $pkgname-zsh-completion"
source="$pkgname-$pkgver.tar.gz::https://github.com/helm/helm/archive/v$pkgver.tar.gz
	unset-CGO_ENABLED.patch
	"

# secfixes:
#   3.6.0-r0:
#     - CVE-2021-21303
#   3.6.1-r0:
#     - CVE-2021-32690

case "$CARCH" in
	# arm*:
	# --- FAIL: TestInvalidYaml (0.01s)
	# lint_test.go:87: All didn't fail with expected errors, got []support.Message(nil)
	# arm*,loongarch64:
	# --- FAIL: TestPlatformPrepareCommand (0.00s)
	# plugin_test.go:45: Expected arg="os-arch", got "linux-riscv64"
	# plugin_test.go:64: Expected arg="os-arch", got "linux-riscv64"
	#
	# riscv64,loongarch64:
	# ../go/github.com/bugsnag/panicwrap@v0.0.0-20151223152923-e2c28503fcd0/dup2.go:10:17: undefined: syscall.Dup2
	# FAIL	helm.sh/helm/v3/cmd/helm [build failed]
	# ...
	# FAIL
	arm*|riscv64|loongarch64) options="$options !check" ;;
esac

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

export GOFLAGS="$GOFLAGS -modcacherw"

build() {
	make GOFLAGS="$GOFLAGS" GIT_TAG="v$pkgver" GIT_COMMIT="" GIT_DIRTY=""

	./bin/helm completion bash > $pkgname.bash
	./bin/helm completion fish > $pkgname.fish
	./bin/helm completion zsh > $pkgname.zsh
}

check() {
	make test-unit GOFLAGS="$GOFLAGS"
}

package() {
	install -Dm755 bin/helm -t "$pkgdir/usr/bin"

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
e3970223dc9401c9261bddf54835855a3d706069d0cdde7fe5ca0419784b0cf711146e24372885a5dc3e2da30268e145f8e4ec13f3bfe868496587a737c0e3b4  helm-3.16.2.tar.gz
94af7ed03f565d85ede2f2a34f6a63a275535a937514740d3fed2ea47418806dcd532857c5103a35b0dd38333315eefd0500568475afc8a16e19a799a2f7c7b7  unset-CGO_ENABLED.patch
"
